const router = require("koa-router")()
const { countDocuments } = require("../models/partner");
const partnerModel = require("../models/partner")

router.prefix("/api");

//查询所有合伙人信息

router.get("/getPartner", async (ctx) => {
    let data = ctx.request.body;
})

//按照姓名查询合伙人信息

//添加合伙人
router.post("/setPartner", async (ctx) => {
    let data = ctx.request.body
    let { partner_name, partner_telephone, sales_volume, agent_level, province, city, area, Wallet_details } = data
    let res = await partnerModel.create({ partner_name, partner_telephone, sales_volume, agent_level, province, city, area, Wallet_details });
    if (res) {
        ctx.body = {
            code: 200,
            msg: "添加合伙人成功"
        }
    } else {
        ctx.body = {
            code: 400,
            msg: "添加合伙人失败"
        }
    }
})


module.exports = router
